{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport * as React from 'react';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport raf from \"rc-util/es/raf\";\nimport { getFocusNodeList } from \"rc-util/es/Dom/focus\";\nimport { getMenuId } from \"../context/IdContext\"; // destruct to reduce minify size\n\nvar LEFT = KeyCode.LEFT,\n  RIGHT = KeyCode.RIGHT,\n  UP = KeyCode.UP,\n  DOWN = KeyCode.DOWN,\n  ENTER = KeyCode.ENTER,\n  ESC = KeyCode.ESC,\n  HOME = KeyCode.HOME,\n  END = KeyCode.END;\nvar ArrowKeys = [UP, DOWN, LEFT, RIGHT];\nfunction getOffset(mode, isRootLevel, isRtl, which) {\n  var _inline, _horizontal, _vertical, _offsets;\n  var prev = 'prev';\n  var next = 'next';\n  var children = 'children';\n  var parent = 'parent'; // Inline enter is special that we use unique operation\n\n  if (mode === 'inline' && which === ENTER) {\n    return {\n      inlineTrigger: true\n    };\n  }\n  var inline = (_inline = {}, _defineProperty(_inline, UP, prev), _defineProperty(_inline, DOWN, next), _inline);\n  var horizontal = (_horizontal = {}, _defineProperty(_horizontal, LEFT, isRtl ? next : prev), _defineProperty(_horizontal, RIGHT, isRtl ? prev : next), _defineProperty(_horizontal, DOWN, children), _defineProperty(_horizontal, ENTER, children), _horizontal);\n  var vertical = (_vertical = {}, _defineProperty(_vertical, UP, prev), _defineProperty(_vertical, DOWN, next), _defineProperty(_vertical, ENTER, children), _defineProperty(_vertical, ESC, parent), _defineProperty(_vertical, LEFT, isRtl ? children : parent), _defineProperty(_vertical, RIGHT, isRtl ? parent : children), _vertical);\n  var offsets = {\n    inline: inline,\n    horizontal: horizontal,\n    vertical: vertical,\n    inlineSub: inline,\n    horizontalSub: vertical,\n    verticalSub: vertical\n  };\n  var type = (_offsets = offsets[\"\".concat(mode).concat(isRootLevel ? '' : 'Sub')]) === null || _offsets === void 0 ? void 0 : _offsets[which];\n  switch (type) {\n    case prev:\n      return {\n        offset: -1,\n        sibling: true\n      };\n    case next:\n      return {\n        offset: 1,\n        sibling: true\n      };\n    case parent:\n      return {\n        offset: -1,\n        sibling: false\n      };\n    case children:\n      return {\n        offset: 1,\n        sibling: false\n      };\n    default:\n      return null;\n  }\n}\nfunction findContainerUL(element) {\n  var current = element;\n  while (current) {\n    if (current.getAttribute('data-menu-list')) {\n      return current;\n    }\n    current = current.parentElement;\n  } // Normally should not reach this line\n\n  /* istanbul ignore next */\n\n  return null;\n}\n/**\n * Find focused element within element set provided\n */\n\nfunction getFocusElement(activeElement, elements) {\n  var current = activeElement || document.activeElement;\n  while (current) {\n    if (elements.has(current)) {\n      return current;\n    }\n    current = current.parentElement;\n  }\n  return null;\n}\n/**\n * Get focusable elements from the element set under provided container\n */\n\nfunction getFocusableElements(container, elements) {\n  var list = getFocusNodeList(container, true);\n  return list.filter(function (ele) {\n    return elements.has(ele);\n  });\n}\nfunction getNextFocusElement(parentQueryContainer, elements, focusMenuElement) {\n  var offset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;\n\n  // Key on the menu item will not get validate parent container\n  if (!parentQueryContainer) {\n    return null;\n  } // List current level menu item elements\n\n  var sameLevelFocusableMenuElementList = getFocusableElements(parentQueryContainer, elements); // Find next focus index\n\n  var count = sameLevelFocusableMenuElementList.length;\n  var focusIndex = sameLevelFocusableMenuElementList.findIndex(function (ele) {\n    return focusMenuElement === ele;\n  });\n  if (offset < 0) {\n    if (focusIndex === -1) {\n      focusIndex = count - 1;\n    } else {\n      focusIndex -= 1;\n    }\n  } else if (offset > 0) {\n    focusIndex += 1;\n  }\n  focusIndex = (focusIndex + count) % count; // Focus menu item\n\n  return sameLevelFocusableMenuElementList[focusIndex];\n}\nexport default function useAccessibility(mode, activeKey, isRtl, id, containerRef, getKeys, getKeyPath, triggerActiveKey, triggerAccessibilityOpen, originOnKeyDown) {\n  var rafRef = React.useRef();\n  var activeRef = React.useRef();\n  activeRef.current = activeKey;\n  var cleanRaf = function cleanRaf() {\n    raf.cancel(rafRef.current);\n  };\n  React.useEffect(function () {\n    return function () {\n      cleanRaf();\n    };\n  }, []);\n  return function (e) {\n    var which = e.which;\n    if ([].concat(ArrowKeys, [ENTER, ESC, HOME, END]).includes(which)) {\n      // Convert key to elements\n      var elements;\n      var key2element;\n      var element2key; // >>> Wrap as function since we use raf for some case\n\n      var refreshElements = function refreshElements() {\n        elements = new Set();\n        key2element = new Map();\n        element2key = new Map();\n        var keys = getKeys();\n        keys.forEach(function (key) {\n          var element = document.querySelector(\"[data-menu-id='\".concat(getMenuId(id, key), \"']\"));\n          if (element) {\n            elements.add(element);\n            element2key.set(element, key);\n            key2element.set(key, element);\n          }\n        });\n        return elements;\n      };\n      refreshElements(); // First we should find current focused MenuItem/SubMenu element\n\n      var activeElement = key2element.get(activeKey);\n      var focusMenuElement = getFocusElement(activeElement, elements);\n      var focusMenuKey = element2key.get(focusMenuElement);\n      var offsetObj = getOffset(mode, getKeyPath(focusMenuKey, true).length === 1, isRtl, which); // Some mode do not have fully arrow operation like inline\n\n      if (!offsetObj && which !== HOME && which !== END) {\n        return;\n      } // Arrow prevent default to avoid page scroll\n\n      if (ArrowKeys.includes(which) || [HOME, END].includes(which)) {\n        e.preventDefault();\n      }\n      var tryFocus = function tryFocus(menuElement) {\n        if (menuElement) {\n          var focusTargetElement = menuElement; // Focus to link instead of menu item if possible\n\n          var link = menuElement.querySelector('a');\n          if (link !== null && link !== void 0 && link.getAttribute('href')) {\n            focusTargetElement = link;\n          }\n          var targetKey = element2key.get(menuElement);\n          triggerActiveKey(targetKey);\n          /**\n           * Do not `useEffect` here since `tryFocus` may trigger async\n           * which makes React sync update the `activeKey`\n           * that force render before `useRef` set the next activeKey\n           */\n\n          cleanRaf();\n          rafRef.current = raf(function () {\n            if (activeRef.current === targetKey) {\n              focusTargetElement.focus();\n            }\n          });\n        }\n      };\n      if ([HOME, END].includes(which) || offsetObj.sibling || !focusMenuElement) {\n        // ========================== Sibling ==========================\n        // Find walkable focus menu element container\n        var parentQueryContainer;\n        if (!focusMenuElement || mode === 'inline') {\n          parentQueryContainer = containerRef.current;\n        } else {\n          parentQueryContainer = findContainerUL(focusMenuElement);\n        } // Get next focus element\n\n        var targetElement;\n        var focusableElements = getFocusableElements(parentQueryContainer, elements);\n        if (which === HOME) {\n          targetElement = focusableElements[0];\n        } else if (which === END) {\n          targetElement = focusableElements[focusableElements.length - 1];\n        } else {\n          targetElement = getNextFocusElement(parentQueryContainer, elements, focusMenuElement, offsetObj.offset);\n        } // Focus menu item\n\n        tryFocus(targetElement); // ======================= InlineTrigger =======================\n      } else if (offsetObj.inlineTrigger) {\n        // Inline trigger no need switch to sub menu item\n        triggerAccessibilityOpen(focusMenuKey); // =========================== Level ===========================\n      } else if (offsetObj.offset > 0) {\n        triggerAccessibilityOpen(focusMenuKey, true);\n        cleanRaf();\n        rafRef.current = raf(function () {\n          // Async should resync elements\n          refreshElements();\n          var controlId = focusMenuElement.getAttribute('aria-controls');\n          var subQueryContainer = document.getElementById(controlId); // Get sub focusable menu item\n\n          var targetElement = getNextFocusElement(subQueryContainer, elements); // Focus menu item\n\n          tryFocus(targetElement);\n        }, 5);\n      } else if (offsetObj.offset < 0) {\n        var keyPath = getKeyPath(focusMenuKey, true);\n        var parentKey = keyPath[keyPath.length - 2];\n        var parentMenuElement = key2element.get(parentKey); // Focus menu item\n\n        triggerAccessibilityOpen(parentKey, false);\n        tryFocus(parentMenuElement);\n      }\n    } // Pass origin key down event\n\n    originOnKeyDown === null || originOnKeyDown === void 0 ? void 0 : originOnKeyDown(e);\n  };\n}","map":{"version":3,"names":["_defineProperty","React","KeyCode","raf","getFocusNodeList","getMenuId","LEFT","RIGHT","UP","DOWN","ENTER","ESC","HOME","END","ArrowKeys","getOffset","mode","isRootLevel","isRtl","which","_inline","_horizontal","_vertical","_offsets","prev","next","children","parent","inlineTrigger","inline","horizontal","vertical","offsets","inlineSub","horizontalSub","verticalSub","type","concat","offset","sibling","findContainerUL","element","current","getAttribute","parentElement","getFocusElement","activeElement","elements","document","has","getFocusableElements","container","list","filter","ele","getNextFocusElement","parentQueryContainer","focusMenuElement","arguments","length","undefined","sameLevelFocusableMenuElementList","count","focusIndex","findIndex","useAccessibility","activeKey","id","containerRef","getKeys","getKeyPath","triggerActiveKey","triggerAccessibilityOpen","originOnKeyDown","rafRef","useRef","activeRef","cleanRaf","cancel","useEffect","e","includes","key2element","element2key","refreshElements","Set","Map","keys","forEach","key","querySelector","add","set","get","focusMenuKey","offsetObj","preventDefault","tryFocus","menuElement","focusTargetElement","link","targetKey","focus","targetElement","focusableElements","controlId","subQueryContainer","getElementById","keyPath","parentKey","parentMenuElement"],"sources":["/data/messenger.client/node_modules/rc-menu/es/hooks/useAccessibility.js"],"sourcesContent":["import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport * as React from 'react';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport raf from \"rc-util/es/raf\";\nimport { getFocusNodeList } from \"rc-util/es/Dom/focus\";\nimport { getMenuId } from \"../context/IdContext\"; // destruct to reduce minify size\n\nvar LEFT = KeyCode.LEFT,\n    RIGHT = KeyCode.RIGHT,\n    UP = KeyCode.UP,\n    DOWN = KeyCode.DOWN,\n    ENTER = KeyCode.ENTER,\n    ESC = KeyCode.ESC,\n    HOME = KeyCode.HOME,\n    END = KeyCode.END;\nvar ArrowKeys = [UP, DOWN, LEFT, RIGHT];\n\nfunction getOffset(mode, isRootLevel, isRtl, which) {\n  var _inline, _horizontal, _vertical, _offsets;\n\n  var prev = 'prev';\n  var next = 'next';\n  var children = 'children';\n  var parent = 'parent'; // Inline enter is special that we use unique operation\n\n  if (mode === 'inline' && which === ENTER) {\n    return {\n      inlineTrigger: true\n    };\n  }\n\n  var inline = (_inline = {}, _defineProperty(_inline, UP, prev), _defineProperty(_inline, DOWN, next), _inline);\n  var horizontal = (_horizontal = {}, _defineProperty(_horizontal, LEFT, isRtl ? next : prev), _defineProperty(_horizontal, RIGHT, isRtl ? prev : next), _defineProperty(_horizontal, DOWN, children), _defineProperty(_horizontal, ENTER, children), _horizontal);\n  var vertical = (_vertical = {}, _defineProperty(_vertical, UP, prev), _defineProperty(_vertical, DOWN, next), _defineProperty(_vertical, ENTER, children), _defineProperty(_vertical, ESC, parent), _defineProperty(_vertical, LEFT, isRtl ? children : parent), _defineProperty(_vertical, RIGHT, isRtl ? parent : children), _vertical);\n  var offsets = {\n    inline: inline,\n    horizontal: horizontal,\n    vertical: vertical,\n    inlineSub: inline,\n    horizontalSub: vertical,\n    verticalSub: vertical\n  };\n  var type = (_offsets = offsets[\"\".concat(mode).concat(isRootLevel ? '' : 'Sub')]) === null || _offsets === void 0 ? void 0 : _offsets[which];\n\n  switch (type) {\n    case prev:\n      return {\n        offset: -1,\n        sibling: true\n      };\n\n    case next:\n      return {\n        offset: 1,\n        sibling: true\n      };\n\n    case parent:\n      return {\n        offset: -1,\n        sibling: false\n      };\n\n    case children:\n      return {\n        offset: 1,\n        sibling: false\n      };\n\n    default:\n      return null;\n  }\n}\n\nfunction findContainerUL(element) {\n  var current = element;\n\n  while (current) {\n    if (current.getAttribute('data-menu-list')) {\n      return current;\n    }\n\n    current = current.parentElement;\n  } // Normally should not reach this line\n\n  /* istanbul ignore next */\n\n\n  return null;\n}\n/**\n * Find focused element within element set provided\n */\n\n\nfunction getFocusElement(activeElement, elements) {\n  var current = activeElement || document.activeElement;\n\n  while (current) {\n    if (elements.has(current)) {\n      return current;\n    }\n\n    current = current.parentElement;\n  }\n\n  return null;\n}\n/**\n * Get focusable elements from the element set under provided container\n */\n\n\nfunction getFocusableElements(container, elements) {\n  var list = getFocusNodeList(container, true);\n  return list.filter(function (ele) {\n    return elements.has(ele);\n  });\n}\n\nfunction getNextFocusElement(parentQueryContainer, elements, focusMenuElement) {\n  var offset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;\n\n  // Key on the menu item will not get validate parent container\n  if (!parentQueryContainer) {\n    return null;\n  } // List current level menu item elements\n\n\n  var sameLevelFocusableMenuElementList = getFocusableElements(parentQueryContainer, elements); // Find next focus index\n\n  var count = sameLevelFocusableMenuElementList.length;\n  var focusIndex = sameLevelFocusableMenuElementList.findIndex(function (ele) {\n    return focusMenuElement === ele;\n  });\n\n  if (offset < 0) {\n    if (focusIndex === -1) {\n      focusIndex = count - 1;\n    } else {\n      focusIndex -= 1;\n    }\n  } else if (offset > 0) {\n    focusIndex += 1;\n  }\n\n  focusIndex = (focusIndex + count) % count; // Focus menu item\n\n  return sameLevelFocusableMenuElementList[focusIndex];\n}\n\nexport default function useAccessibility(mode, activeKey, isRtl, id, containerRef, getKeys, getKeyPath, triggerActiveKey, triggerAccessibilityOpen, originOnKeyDown) {\n  var rafRef = React.useRef();\n  var activeRef = React.useRef();\n  activeRef.current = activeKey;\n\n  var cleanRaf = function cleanRaf() {\n    raf.cancel(rafRef.current);\n  };\n\n  React.useEffect(function () {\n    return function () {\n      cleanRaf();\n    };\n  }, []);\n  return function (e) {\n    var which = e.which;\n\n    if ([].concat(ArrowKeys, [ENTER, ESC, HOME, END]).includes(which)) {\n      // Convert key to elements\n      var elements;\n      var key2element;\n      var element2key; // >>> Wrap as function since we use raf for some case\n\n      var refreshElements = function refreshElements() {\n        elements = new Set();\n        key2element = new Map();\n        element2key = new Map();\n        var keys = getKeys();\n        keys.forEach(function (key) {\n          var element = document.querySelector(\"[data-menu-id='\".concat(getMenuId(id, key), \"']\"));\n\n          if (element) {\n            elements.add(element);\n            element2key.set(element, key);\n            key2element.set(key, element);\n          }\n        });\n        return elements;\n      };\n\n      refreshElements(); // First we should find current focused MenuItem/SubMenu element\n\n      var activeElement = key2element.get(activeKey);\n      var focusMenuElement = getFocusElement(activeElement, elements);\n      var focusMenuKey = element2key.get(focusMenuElement);\n      var offsetObj = getOffset(mode, getKeyPath(focusMenuKey, true).length === 1, isRtl, which); // Some mode do not have fully arrow operation like inline\n\n      if (!offsetObj && which !== HOME && which !== END) {\n        return;\n      } // Arrow prevent default to avoid page scroll\n\n\n      if (ArrowKeys.includes(which) || [HOME, END].includes(which)) {\n        e.preventDefault();\n      }\n\n      var tryFocus = function tryFocus(menuElement) {\n        if (menuElement) {\n          var focusTargetElement = menuElement; // Focus to link instead of menu item if possible\n\n          var link = menuElement.querySelector('a');\n\n          if (link !== null && link !== void 0 && link.getAttribute('href')) {\n            focusTargetElement = link;\n          }\n\n          var targetKey = element2key.get(menuElement);\n          triggerActiveKey(targetKey);\n          /**\n           * Do not `useEffect` here since `tryFocus` may trigger async\n           * which makes React sync update the `activeKey`\n           * that force render before `useRef` set the next activeKey\n           */\n\n          cleanRaf();\n          rafRef.current = raf(function () {\n            if (activeRef.current === targetKey) {\n              focusTargetElement.focus();\n            }\n          });\n        }\n      };\n\n      if ([HOME, END].includes(which) || offsetObj.sibling || !focusMenuElement) {\n        // ========================== Sibling ==========================\n        // Find walkable focus menu element container\n        var parentQueryContainer;\n\n        if (!focusMenuElement || mode === 'inline') {\n          parentQueryContainer = containerRef.current;\n        } else {\n          parentQueryContainer = findContainerUL(focusMenuElement);\n        } // Get next focus element\n\n\n        var targetElement;\n        var focusableElements = getFocusableElements(parentQueryContainer, elements);\n\n        if (which === HOME) {\n          targetElement = focusableElements[0];\n        } else if (which === END) {\n          targetElement = focusableElements[focusableElements.length - 1];\n        } else {\n          targetElement = getNextFocusElement(parentQueryContainer, elements, focusMenuElement, offsetObj.offset);\n        } // Focus menu item\n\n\n        tryFocus(targetElement); // ======================= InlineTrigger =======================\n      } else if (offsetObj.inlineTrigger) {\n        // Inline trigger no need switch to sub menu item\n        triggerAccessibilityOpen(focusMenuKey); // =========================== Level ===========================\n      } else if (offsetObj.offset > 0) {\n        triggerAccessibilityOpen(focusMenuKey, true);\n        cleanRaf();\n        rafRef.current = raf(function () {\n          // Async should resync elements\n          refreshElements();\n          var controlId = focusMenuElement.getAttribute('aria-controls');\n          var subQueryContainer = document.getElementById(controlId); // Get sub focusable menu item\n\n          var targetElement = getNextFocusElement(subQueryContainer, elements); // Focus menu item\n\n          tryFocus(targetElement);\n        }, 5);\n      } else if (offsetObj.offset < 0) {\n        var keyPath = getKeyPath(focusMenuKey, true);\n        var parentKey = keyPath[keyPath.length - 2];\n        var parentMenuElement = key2element.get(parentKey); // Focus menu item\n\n        triggerAccessibilityOpen(parentKey, false);\n        tryFocus(parentMenuElement);\n      }\n    } // Pass origin key down event\n\n\n    originOnKeyDown === null || originOnKeyDown === void 0 ? void 0 : originOnKeyDown(e);\n  };\n}"],"mappings":"AAAA,OAAOA,eAAe,MAAM,2CAA2C;AACvE,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,OAAOC,OAAO,MAAM,oBAAoB;AACxC,OAAOC,GAAG,MAAM,gBAAgB;AAChC,SAASC,gBAAgB,QAAQ,sBAAsB;AACvD,SAASC,SAAS,QAAQ,sBAAsB,CAAC,CAAC;;AAElD,IAAIC,IAAI,GAAGJ,OAAO,CAACI,IAAI;EACnBC,KAAK,GAAGL,OAAO,CAACK,KAAK;EACrBC,EAAE,GAAGN,OAAO,CAACM,EAAE;EACfC,IAAI,GAAGP,OAAO,CAACO,IAAI;EACnBC,KAAK,GAAGR,OAAO,CAACQ,KAAK;EACrBC,GAAG,GAAGT,OAAO,CAACS,GAAG;EACjBC,IAAI,GAAGV,OAAO,CAACU,IAAI;EACnBC,GAAG,GAAGX,OAAO,CAACW,GAAG;AACrB,IAAIC,SAAS,GAAG,CAACN,EAAE,EAAEC,IAAI,EAAEH,IAAI,EAAEC,KAAK,CAAC;AAEvC,SAASQ,SAAS,CAACC,IAAI,EAAEC,WAAW,EAAEC,KAAK,EAAEC,KAAK,EAAE;EAClD,IAAIC,OAAO,EAAEC,WAAW,EAAEC,SAAS,EAAEC,QAAQ;EAE7C,IAAIC,IAAI,GAAG,MAAM;EACjB,IAAIC,IAAI,GAAG,MAAM;EACjB,IAAIC,QAAQ,GAAG,UAAU;EACzB,IAAIC,MAAM,GAAG,QAAQ,CAAC,CAAC;;EAEvB,IAAIX,IAAI,KAAK,QAAQ,IAAIG,KAAK,KAAKT,KAAK,EAAE;I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